package com.jet.core.annotation;

import com.jet.core.enums.RepeatSubmitStrategy;

import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;

/**
 * 重复提交锁
 *
 * @author dcl
 * @since 2024/12/23 18:05
 */
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface RepeatSubmitLock {
    String key() default "";

    RepeatSubmitStrategy strategy() default RepeatSubmitStrategy.ALL_FIELD;

    /**
     * 尝试获取锁，等待时长，默认0
     *
     * @return
     */
    long waitTime() default 0;

    /**
     * 持有锁时长，默认-1毫秒
     * <p>
     * 时长小于0可以自动设置过期时间并触发看门狗机制
     */
    long leaseTime() default -1;

    /**
     * 时长单位，默认毫秒
     */
    TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
}
